import { request } from './request';

// 用户相关API
export const userApi = {
  // 登录
  login: (data: { username: string; password: string }) => 
    request.post('/auth/login', data),
  
  // 注册
  register: (data: { username: string; email: string; password: string }) => 
    request.post('/auth/register', data),
  
  // 获取用户信息
  getUserInfo: () => 
    request.get('/user/info'),
  
  // 更新用户信息
  updateUserInfo: (data: any) => 
    request.put('/user/info', data),
};

// 场地相关API
export const venueApi = {
  // 获取场地列表
  getVenues: (params?: any) => 
    request.get('/venues', { params }),
  
  // 获取场地详情
  getVenueDetail: (id: string) => 
    request.get(`/venues/${id}`),
  
  // 预订场地
  bookVenue: (data: any) => 
    request.post('/venues/book', data),
};

// 课程相关API
export const courseApi = {
  // 获取课程列表
  getCourses: (params?: any) => 
    request.get('/courses', { params }),
  
  // 获取课程详情
  getCourseDetail: (id: string) => 
    request.get(`/courses/${id}`),
  
  // 报名课程
  enrollCourse: (data: any) => 
    request.post('/courses/enroll', data),
};

// 企业研学相关API
export const enterpriseApi = {
  // 获取企业研学项目列表
  getProjects: (params?: any) => 
    request.get('/enterprise/projects', { params }),
  
  // 获取项目详情
  getProjectDetail: (id: string) => 
    request.get(`/enterprise/projects/${id}`),
};

// 器材租赁相关API
export const equipmentApi = {
  // 获取器材列表
  getEquipmentList: (params?: any) => 
    request.get('/equipment', { params }),
  
  // 获取器材详情
  getEquipmentDetail: (id: string) => 
    request.get(`/equipment/${id}`),
  
  // 租赁器材
  rentEquipment: (data: any) => 
    request.post('/equipment/rent', data),
};

// 首页数据API
export const homeApi = {
  // 获取首页统计数据
  getHomeStats: () => 
    request.get('/home/stats'),
  
  // 获取最新动态
  getLatestNews: () => 
    request.get('/home/news'),
};
